<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <title>优惠券</title>

    <link href="css/haibao.css" rel="stylesheet" type="text/css">
    <link href="css/public.css" rel="stylesheet" type="text/css">
    <link href="css/cart.css" rel="stylesheet" type="text/css">
    <script src="./js/config.js"></script>
    <script src="js/jquery-1.7.1.min.js"></script>
    <script src="js/js.js"></script>

</head>
<body>

<div class="baby-main" id="con" style="background:#FFEFDF;">
    <section class="m-page ">
        <div class="m-img" id="beijing" style="background-size:100% 100%;"></div>
        <div class="m-input"><input type="tel" placeholder=" 请输入您的手机号码" name="mb" id="mb"></div>
        <div class="m-btn">
            <a href="javascript:;" id="isphone" onclick="isphone2()">
                <img id="lingqu" src="images/btn1.png" width="100%" alt=""/>
            </a>
        </div>
        <div class="m-btn2">
            <a href="javascript:void(0)" data-role="btn">
                <img id="fenxiang" src="images/btn2.png" width="100%" alt=""/>
            </a>
        </div>
    </section>

    <!--分享朋友圈-->
    <div class="mask" id="mask"></div>
    <div class="loading trantion" id="ios">
        <img src="images/fenxiang.png" alt="下载app"/>
    </div>
    <div class="loading trantion" id="android">
        <img src="images/fenxiang.png" alt="下载app"/>
    </div>
</div>

<script>
    $(function () {
        var activity_key = GetQueryString("activitykey");
        $.ajax({
            url: ip+"home/getActivityById",
            type: "POST",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify({
                "activity_key": activity_key,
            }),
            dataType: "json",
            success: function (data) {
                $('#lingqu').src = data.body.receivebtn_url;
                $('#fenxiang').src = data.body.sharebtn_url;
                $('#beijing').css("background-image", "url(" + data.body.background_url + ")");
            }
        })
    })

    function isphone2() {
        var num = document.getElementById('mb').value;
        var partten = /^1[3,5,4,8,7]\d{9}$/;
        var activity_key = GetQueryString("activitykey");

        if (activity_key != '') {
            if (partten.test(num)) {
                $.ajax({
                    url: ip+"home/receive",
                    type: "POST",
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify({
                        "phone": num,
                        "activity_key": activity_key
                    }),
                    dataType: "json",
                    success: function (data) {
                        alert(data.header.message);
                    }
                })
            } else {
                alert('手机号码不正确');
                setTimeout(function () {
                    $("#isphone").one("click", isphone2)
                }, 1);
            }
        }


    }


    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

</script>
</body>
</html>
